package com.xpec.c4.service.module.task;

import org.jgroups.Address;

import com.xpec.c4.game.utility.GUID;

/**
 * 
 * @author yangbingyan
 *
 */
public class TaskNetMessage extends TaskObject{

	/**
	 * 
	 */
	private int messageType;
	
	/**
	 * 同步Id
	 */
	private int syncId;

	/**
	 * 
	 */
	private byte[] messageContentBytes;
	
	/**
	 * 
	 */
	private GUID sessionID;
	
	/**
	 * 
	 */
	private String moduleID;
	
	/**
	 * 
	 */
	private String srcService;
	
	/**
	 * 訊息來源位址 返回值要送回去
	 */
	private Address srcAddress;
	
	/**
	 * 是否要處理Action的return
	 */
	private boolean syncReturn = true;
	
	/**
	 * 
	 */
	private int options;
	
	
	public int getMessageType() {
		return messageType;
	}

	public void setMessageType(int messageType) {
		this.messageType = messageType;
	}
	
	public int getSyncId() {
		return syncId;
	}

	public void setSyncId(int syncId) {
		this.syncId = syncId;
	}

	public byte[] getMessageContentBytes() {
		return messageContentBytes;
	}

	public void setMessageContentBytes(byte[] messageContentBytes) {
		this.messageContentBytes = messageContentBytes;
	}

	public GUID getSessionID() {
		return sessionID;
	}

	public void setSessionID(GUID sessionID) {
		this.sessionID = sessionID;
	}

	public int getOptions() {
		return options;
	}

	public void setOptions(int options) {
		this.options = options;
	}

	public void setModuleID(String moduleID) {
		this.moduleID = moduleID;
	}

	public String getModuleID() {
		return moduleID;
	}

	public void setSrcService(String srcService) {
		this.srcService = srcService;
	}

	public String getSrcService() {
		return srcService;
	}

	public void setSrcAddress(Address srcAddress) {
		this.srcAddress = srcAddress;
	}

	public Address getSrcAddress() {
		return srcAddress;
	}

	public void setSyncReturn(boolean syncReturn) {
		this.syncReturn = syncReturn;
	}

	public boolean getSyncReturn() {
		return syncReturn;
	}
	
	@Override
	public void execute() {		
	}

	@Override
	public void procTask(){

		if(this.getModuleServer() != null){
			this.getModuleServer().procNetworkMessage(this);
		}
	}
	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("syncId=").append(syncId).append(",sessionID=").append(sessionID).append(",moduleID=").append(moduleID)
		.append(",srcService=").append(srcService).append(",srcAddress=").append(srcAddress).append(",syncReturn=").append(syncReturn)
		.append(",options=").append(options);
		return sb.toString();
	}		
	
}
